/***************************************************
Class: Mesh
Includes: stdafx.h, WorldTransformation
Editors: Gindi
Existing Issues: None
Description: Classes for Mesh and MeshInstance.
***************************************************/
#pragma once

#include "stdafx.h"
#include "WorldTransformation.h"

class Mesh {
public:
	Mesh();
	~Mesh() { Release(); }
	bool Load(LPDIRECT3DDEVICE9 pDevice, char* file);
	bool Load(LPDIRECT3DDEVICE9 pDevice, string file);
	void Release();

	LPD3DXMESH getMesh()						{ return m_pMesh; }
	DWORD getNumMaterials()						{ return m_numMaterials; }
	D3DMATERIAL9* getMeshMaterial(int i)		{ return &m_pMeshMaterials[i]; }
	LPDIRECT3DTEXTURE9 getMeshTexture(int i)	{ return m_ppMeshTextures[i]; }

private:
	LPD3DXMESH			m_pMesh;
	DWORD				m_numMaterials;
	D3DMATERIAL9*		m_pMeshMaterials;
	LPDIRECT3DTEXTURE9*	m_ppMeshTextures;
};


// holds a mesh, inherits traits from class WorldTransform
class MeshInstance : public WorldTransform {
public:
	MeshInstance();
	~MeshInstance() { Release(); }

	void Release();
	void setMesh(Mesh* pMesh);
	void Render(LPDIRECT3DDEVICE9 pevice);

	void setBoundingRadius(float radius) { m_boundingRadius = radius; }
	float getBoundingRadius() { return m_boundingRadius; }

private:
	Mesh* m_pMesh;
	float m_boundingRadius;
};
